package com.ipudong.widget.recycleview;

import android.content.Context;
import android.graphics.Rect;
import android.support.v7.widget.RecyclerView;
import android.widget.LinearLayout;

public class DividerItemDecoration extends RecyclerView.ItemDecoration {


	public static final int HORIZONTAL_LIST = LinearLayout.HORIZONTAL;

	public static final int VERTICAL_LIST = LinearLayout.VERTICAL;

	// 健康履历的样式设计
	public static final int RECORD_MODAL = 1;

	// 用药记录的样式设计
	public static final int DRUG_INSTRUCTION_MODAL = 2;

	private int mOrientation;

	private int mModalType;

	public DividerItemDecoration (Context context, int orientation, int modalType) {
		setOrientation (orientation);
		this.mModalType = modalType;
	}

	public void setOrientation (int orientation) {
		if (orientation != HORIZONTAL_LIST && orientation != VERTICAL_LIST) {
			throw new IllegalArgumentException ("invalid orientation");
		}
		mOrientation = orientation;
	}

	@Override
	public void getItemOffsets (Rect outRect, int itemPosition, RecyclerView parent) {
		if (mModalType == RECORD_MODAL) {
			if (mOrientation == VERTICAL_LIST) {
				outRect.set (0, 0, 0, 12);
			} else {
				outRect.set (0, 0, 12, 0);
			}
		} else if (mModalType == DRUG_INSTRUCTION_MODAL) {
			outRect.set (0, 0, 0, 24);
		}
	}
}